package com.kerbores.jfinal.controller;

import com.jfinal.core.ActionKey;
import com.kerbores.jfinal.controller.base.BaseController;
import com.kerbores.jfinal.service.BlogService;
import com.kerbores.utils.annotation.ControllerKey;
import com.kerbores.utils.entries.Result;
import com.kerbores.utils.ua.UserAgent;

/**
 * @author 王贵源
 *
 *         create at 2014年9月22日 下午9:22:22
 */
@ControllerKey("/")
public class CommonController extends BaseController {

	private BlogService blogService = new BlogService();

	@ActionKey("j")
	public void test() {
		data.put("a", 123);
		data.put("blogs", blogService.findAll());
		result = Result.success().setData(data);
		jsonRender(result);
	}

	public void test1() {
		result = Result.success();
		data.put("b", 234);
		data.put("ua", new UserAgent(getRequest().getHeader("user-agent")));
		jsonRender(result.setData(data));
	}

	public void index() {
		result = Result.success().setTitle("11111");
		jspRender("/WEB-INF/index.jsp");
	}

}
